package com.epro.dx.adapter;

import java.util.ArrayList;

import com.epro.dx.util.DpPxUtils;

import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

/**
 * @author tony
 * 选择年月的列表适配器
 */
public class ChooseYearMonthListAdapter extends BaseAdapter {

	private ArrayList<String> textList;
	private Context mContext;

	public ChooseYearMonthListAdapter(Context mContext,ArrayList<String> textList){
		this.mContext = mContext;
		this.textList = textList;
		
	}
	@Override
	public int getCount() {
		if(null!=textList){
			return textList.size();
		}
		return 0;
	}

	@Override
	public String getItem(int position) {
		return textList.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup group) {
		TextView text ;
		if(null==convertView){
			text = new TextView(mContext);
			text.setGravity(Gravity.CENTER_HORIZONTAL);
			text.setTextSize(DpPxUtils.Dp2Px(mContext, 12));
			text.setPadding(0, DpPxUtils.Dp2Px(mContext, 3), 0, DpPxUtils.Dp2Px(mContext, 3));
			convertView = text;
			convertView.setTag(text);
		}else{
			text = (TextView) convertView.getTag();
		}
		text.setText(textList.get(position));
		return convertView;
	}

}
